<{include file="Toy/toy_top.html"}>
    </head>
    <body>
    	<div id="wrap">
			<{include file="Toy/toy_nav.html"}>
    		<div class="container myPrefer">
				<!--无搜索结果显示-->
				<div class="nodata" style="display:none ;">未搜索到任何信息</div>
    			<ul>
					<{foreach from=$list item=item}>
    				<li>
    					<div class="img-box">
    						<a href="<{u('detail?itemId='|cat:$item.id)}>" style="display: inline"> <img src="<{$item.headpic}>" /></a>
    					</div>
    					<div class="detail">
    						<p><label>上架时间: </label><{$item.addTime|date_format:'%m-%d %H:%M'}></p>
    						<p><label>到期时间: </label><{($item.auditTime+$effectiveTime)|date_format:'%m-%d %H:%M'}></p>
    						<p class="state state-<{$item.status}>">
    							<label>状态: </label><span ><{$statusKV[$item.status]}></span>
								<{if $item.status eq $statusAudit}>
								<{elseif $item.status eq $statusOnline}>
									<a href="javascript:void(0);" class="off" onclick="onlineOffline(this,<{$item.id}>)">立即下架</a>
								<{elseif $item.status eq $statusOffline}>
									<a href="javascript:void(0);" class="off" onclick="onlineOffline(this,<{$item.id}>)">重新上架</a>
								<{elseif $item.status eq $statusSuccess or $item.status eq $statusInTrading }>
									<a href="<{u('detail?itemId='|cat:$item.id)}>" class="off">查看信息</a>
								<{elseif $item.status eq $statusRefuse}>
									<a href="javascript:void(0);" class="off" onclick="showReason(<{$item.id}>)">查看原因</a>
								<{/if}>
    						</p>
    					</div>
							<{if $item.status eq $statusOffline }>
								<a href="<{u('publish?id='|cat:$item.id)}>" class="edit"></a>
							<{/if}>

							<{if $item.status eq $statusOffline or $item.status eq $statusRefuse }>
								<a href="javascript:void(0);" class="del" onclick="deleteItem(this,<{$item.id}>)"></a>
							<{/if}>
    				</li>
					<{/foreach}>

    			</ul>
				<a href="<{u('publish')}>" class="plus"></a>
    		</div>

			<{include file="Toy/toy_foot.html"}>
    	</div>
    	<script src="<{$preStaticUrl}>Wap/js/jquery-2.1.4.min.js"></script>
    	<script src="<{$preStaticUrl}>Wap/toy/js/index.js"></script>
	<script>

		function onlineOffline(obj,itemId){
			$.ajax({
				type:"post",
				url:"<{u('onlineOffline')}>",
				dataType: 'json',
				data: {id:itemId},
				success: function(data){
					if(data.status==0){
						if(data.online=='<{$statusOnline}>'){
									$(obj).text('立即下架').prev().text('上架中')
						}else if(data.online=='<{$statusOffline}>'){
									$(obj).text('重新上架').prev().text('已下架');
						}
					}
					tip(data.msg);
				}
			});
		}

		function deleteItem(obj,itemId){
			var sure=window.confirm("确定删除该宝贝吗？删除后不可恢复");
			if(!sure) return false;
			$.ajax({
				type:"post",
				url:"<{u('deleteItem')}>",
				dataType: 'json',
				data: {id:itemId},
				success: function(data){
					if(data.status==0){
						tip(data.msg);

					}else{
						tip(data.msg);
					}
				}
			});
		}

		function showReason(itemId){
			$.ajax({
				type:"post",
				url:"<{u('showReason')}>",
				dataType: 'json',
				data: {id:itemId},
				success: function(data){
					if(data.status==0) {
						tip(data.reason,null,5);
					}else{
						tip(data.msg);
					}
				}
			});
		}


	</script>
	</body>
</html>
